﻿using System;
using System.ComponentModel;
using System.Reflection;

namespace Common
{
    /// <summary>
    /// 常数类
    /// </summary>
    public class Constant
    {
        /// <summary>
        /// 统一管理操作枚举
        /// </summary>
        public enum ActionEnum
        {
            /// <summary>
            /// 显示
            /// </summary>
            [Description("Show")]
            Show,

            /// <summary>
            /// 查看
            /// </summary>
            [Description("View")]
            View,

            /// <summary>
            /// 添加
            /// </summary>
            [Description("Add")]
            Add,

            /// <summary>
            /// 修改
            /// </summary>
            [Description("Edit")]
            Edit,

            /// <summary>
            /// 删除
            /// </summary>
            [Description("Delete")]
            Delete,

            /// <summary>
            /// 审核
            /// </summary>
            [Description("Audit")]
            Audit,

            /// <summary>
            /// 反审核
            /// </summary>
            [Description("ReAudit")]
            ReAudit,

            /// <summary>
            /// 回复
            /// </summary>
            [Description("Reply")]
            Reply,

            /// <summary>
            /// 确认
            /// </summary>
            [Description("Confirm")]
            Confirm,

            /// <summary>
            /// 取消
            /// </summary>
            [Description("Cancel")]
            Cancel,

            /// <summary>
            /// 作废
            /// </summary>
            [Description("Invalid")]
            Invalid,

            /// <summary>
            /// 生成
            /// </summary>
            [Description("Build")]
            Build,

            /// <summary>
            /// 安装
            /// </summary>
            [Description("Instal")]
            Instal,

            /// <summary>
            /// 卸载
            /// </summary>
            [Description("UnLoad")]
            UnLoad,

            /// <summary>
            /// 登录
            /// </summary>
            [Description("Login")]
            Login,

            /// <summary>
            /// 备份
            /// </summary>
            [Description("Back")]
            Back,

            /// <summary>
            /// 还原
            /// </summary>
            [Description("Restore")]
            Restore,

            /// <summary>
            /// 替换
            /// </summary>
            [Description("Replace")]
            Replace,

            /// <summary>
            /// 复制
            /// </summary>
            [Description("Copy")]
            Copy,

            /// <summary>
            /// 下载
            /// </summary>
            [Description("Download")]
            Download,

            /// <summary>
            /// 导出
            /// </summary>
            [Description("Export")]
            Export,

            /// <summary>
            /// 导入
            /// </summary>
            [Description("Import")]
            Import,

            /// <summary>
            /// 打印
            /// </summary>
            [Description("Print")]
            Print,

            /// <summary>
            /// 启用/禁用
            /// </summary>
            [Description("Enabled")]
            Enabled,

            /// <summary>
            /// 上传
            /// </summary>
            [Description("Upload")]
            Upload
        }

        /// <summary>
        /// 操作状态枚举
        /// </summary>
        public enum StatusEnum
        {
            /// <summary>
            /// 操作成功
            /// </summary>
            [Description("Success")]
            Success,

            /// <summary>
            /// 操作失败
            /// </summary>
            [Description("Fail")]
            Fail,

            /// <summary>
            /// 操作异常
            /// </summary>
            [Description("Exception")]
            Exception
        }

        /// <summary>
        /// 模块管理枚举
        /// </summary>
        public enum SysModule
        {
            /// <summary>
            /// 首页
            /// </summary>
            [Description("首页")]
            Home,

            /// <summary>
            /// 登录
            /// </summary>
            [Description("登录")]
            Login,

            /// <summary>
            /// 用户管理
            /// </summary>
            [Description("用户管理")]
            User,

            /// <summary>
            /// 角色管理
            /// </summary>
            [Description("角色管理")]
            Role,

            /// <summary>
            /// 岗位管理
            /// </summary>
            [Description("岗位管理")]
            Post,

            /// <summary>
            /// 部门管理
            /// </summary>
            [Description("部门管理")]
            Dept,

            /// <summary>
            /// 仓库管理
            /// </summary>
            [Description("仓库管理")]
            Store,

            /// <summary>
            /// 认证管理
            /// </summary>
            [Description("认证管理")]
            Audit,

            /// <summary>
            /// 系统日志
            /// </summary>
            [Description("系统日志")]
            SysLog,

            /// <summary>
            /// 上传文件
            /// </summary>
            [Description("上传文件")]
            Upload,

            /// <summary>
            /// 人员管理
            /// </summary>
            [Description("人员管理")]
            Staff,

            /// <summary>
            /// 物品资料
            /// </summary>
            [Description("物品资料")]
            Item,

            /// <summary>
            /// 供应商管理
            /// </summary>
            [Description("供应商管理")]
            Supplier,

            /// <summary>
            /// 采购申请
            /// </summary>
            [Description("采购申请")]
            PurchaseRequest,

            /// <summary>
            /// 采购订单
            /// </summary>
            [Description("采购订单")]
            PurchaseOrder,

            /// <summary>
            /// 采购变更
            /// </summary>
            [Description("采购变更")]
            PurchaseAlter,

            /// <summary>
            /// 收货管理
            /// </summary>
            [Description("收货管理")]
            PurchaseGet,

            /// <summary>
            /// 付款申请
            /// </summary>
            [Description("付款申请")]
            PurchasePayApply,

            /// <summary>
            /// 付款登记
            /// </summary>
            [Description("付款登记")]
            PurchasePayRegist,

            /// <summary>
            /// 资产入库
            /// </summary>
            [Description("资产入库")]
            AssetInv,
            /// <summary>
            /// 资产标签
            /// </summary>
            [Description("资产标签")]
            AssetTag,
            /// <summary>
            /// 资产维护提醒
            /// </summary>
            [Description("资产维护提醒")]
            AssetKeepWarn,
            /// <summary>
            /// 资产维护登记
            /// </summary>
            [Description("资产维护登记")]
            AssetUpKeep,
            /// <summary>
            /// 资产领用归还
            /// </summary>
            [Description("资产领用归还")]
            AssetUseReturn,
            /// <summary>
            /// 资产调拨
            /// </summary>
            [Description("资产调拨")]
            AssetTransfer,
            /// <summary>
            /// 定时任务
            /// </summary>
            [Description("定时任务")]
            QuartzJob
        }

        /// <summary>
        /// 获取枚举类型的描述信息
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static string GetActionDescription(Enum action)
        {
            FieldInfo field = action.GetType().GetField(action.ToString());

            DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;

            return attribute == null ? action.ToString() : attribute.Description;
        }
    }
}